<?php
$this->breadcrumbs=array(
	'Quizs'=>array('admin'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Quiz', 'url'=>array('index')),
	array('label'=>'Create Quiz', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('quiz-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Test</h1>
<?php if(Yii::app()->user->hasFlash('success')):?>
   <div class="flash-success" style="color:white;background-color:#669966;">
   <?php echo Yii::app()->user->getFlash('success'); ?>
</div>
<?php endif; ?>
<div class="search-form" >
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
<div class="row">
<a href="<?php echo Yii::app()->createUrl('/admin/quiz/create');?>" class="button_design">Add Quiz</a>
</div>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'quiz-grid',
	'dataProvider'=>$model->search(),
	'htmlOptions'=>array('style'=>'cursor: pointer;'),
	'selectionChanged'=>"function(id){window.location='" . Yii::app()->urlManager->createUrl('admin/questions/admin', array('id'=>'')) . "/' + $.fn.yiiGridView.getSelection(id);}",
	'columns'=>array(
		
		'id',
		array('name'=>'category_id','value'=>'Category::model()->findByPk($data->category_id)->name','htmlOptions'=>array('width'=>'20px')),
		'title',
		'status',
		'time',
		array(
			'htmlOptions'=>array('width'=>'100px'),
			'class'=>'CButtonColumn',
			'template'=>'{update}{remove}{create}{manage_questions}',
			'buttons'=>array(
						'remove' => array(
                                'label'=>'Delete', // text label of the button
                                'url'=>"CHtml::normalizeUrl(array('/admin/Quiz/delete', 'id'=>\$data->id))",
                               	'imageUrl'=>"/clients/quize/images/delete.png",  // image URL of the button. If not set or false, a text link is used
                                'options' => array('confirm'=>"Are you sure?"), // HTML options for the button
                        ), 
					
						'create' => array(
							
                                'label'=>'Create Question', // text label of the button
                                'url'=>"CHtml::normalizeUrl(array('/admin/questions/create','id'=>\$data->id))",
                               'imageUrl'=>"/clients/quize/images/add_quiz.png",  // image URL of the button. If not set or false, a text link is used
                                'options' => array('class'=>'add'), // HTML options for the button
                        ),
                        'manage_questions' => array(
                        		
                                'label'=>'Manage Question', // text label of the button
                                'url'=>"CHtml::normalizeUrl(array('/admin/questions/admin', 'id'=>\$data->id))",
                               'imageUrl'=>"/clients/quize/images/manage_quiz.png",  // image URL of the button. If not set or false, a text link is used
                                'options' => array('class'=>'add'), // HTML options for the button
                        ),
    
                      ),
		),
	),
)); ?>

